What is faster: multiple `send`s or using buffering?

Posted by dauerbaustelle on Stack Overflow See other posts from Stack Overflow or by dauerbaustelle
Published on 2010-04-14T15:04:48Z Indexed on 2010/04/14 15:13 UTC
Read the original article Hit count: 210

Filed under:
|
|
|
|

I'm playing around with sockets in C/Python and I wonder what is the most efficient way to send headers from a Python dictionary to the client socket.

My ideas:

  1. use a send call for every header. Pros: No memory allocation needed. Cons: many send calls -- probably error prone; error management should be rather complicated
  2. use a buffer. Pros: one send call, error checking a lot easier. Cons: Need a buffer :-) malloc/realloc should be rather slow and using a (too) big buffer to avoid realloc calls wastes memory.

Any tips for me? Thanks :-)

© Stack Overflow or respective owner

Related posts about c

    Related posts about socket